package com.sunfeng.chap1;

import java.nio.CharBuffer;

public class Test4 {
    public static void main(String[] args) {
        // 获取当前位置position和limit之间的差值

        char[] charArray = new char[]{'a', 'b', 'c', 'd','e'};
        CharBuffer charBuffer = CharBuffer.wrap(charArray);

        System.out.println("capacity()="+charBuffer.capacity()+" limit()="+charBuffer.limit()+" position()="+charBuffer.position());
        charBuffer.position(2);
        System.out.println("capacity()="+charBuffer.capacity()+" limit()="+charBuffer.limit()+" position()="+charBuffer.position());
        System.out.println(charBuffer.remaining());
    }
}
